package com.party.core.service.serviceguide.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.common.utils.UUIDUtils;
import com.party.core.dao.read.serviceguide.ServiceGuideRelationReadDao;
import com.party.core.dao.write.serviceguide.ServiceGuideRelationWriteDao;
import com.party.core.model.serviceguide.ServiceGuideRelation;
import com.party.core.service.serviceguide.IServiceGuideRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @program: party
 * @description: 服务指南类型关系业务接口实现
 * @author: Hua Qunhao
 * @create: 2019-04-17 09:26
 **/
@Service("ServiceGuideRelationService")
public class ServiceGuideRelationService implements IServiceGuideRelationService {
    @Autowired
    private ServiceGuideRelationReadDao serviceGuideRelationReadDao;

    @Autowired
    private ServiceGuideRelationWriteDao serviceGuideRelationWriteDao;

    @Override
    public String insert(ServiceGuideRelation t) {
        String uuid = UUIDUtils.generateRandomUUID();
        if (Strings.isNullOrEmpty(t.getId())) {
            t.setId(uuid);
        }
        boolean result = serviceGuideRelationWriteDao.insert(t);
        if (result) {
            return t.getId();
        }
        return null;
    }

    @Override
    public boolean update(ServiceGuideRelation serviceGuideRelation) {
        return serviceGuideRelationWriteDao.update(serviceGuideRelation);
    }

    @Override
    public boolean deleteLogic(String id) {
        return serviceGuideRelationWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        return serviceGuideRelationWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ServiceGuideRelation get(String id) {
        return serviceGuideRelationReadDao.get(id);
    }

    @Override
    public List<ServiceGuideRelation> listPage(ServiceGuideRelation serviceGuideRelation, Page page) {
        return serviceGuideRelationReadDao.listPage(serviceGuideRelation,page);
    }

    @Override
    public List<ServiceGuideRelation> list(ServiceGuideRelation serviceGuideRelation) {
        return serviceGuideRelationReadDao.listPage(serviceGuideRelation,null);
    }

    @Override
    public List<ServiceGuideRelation> batchList(Set<String> ids, ServiceGuideRelation serviceGuideRelation, Page page) {
        return null;
    }

    @Override
    public void deleteSGR(ServiceGuideRelation serviceGuideRelation) {
        serviceGuideRelationWriteDao.deleteSGR(serviceGuideRelation);
    }
}
